<template>
  <base-breadcrumb>
    <div class="about-master-container">
      <BForms ref="form">
        <a-card v-loading="loading">
          <title-name title="资产基本信息" />
          <BForm
            :config="formConfig"
            :form="form"
          />
          <template
            v-if="form.assetAccessoriesInformations && form.assetAccessoriesInformations.length"
            v-loading="loading"
          >
            <title-name title="配件信息" />
            <part
              :disabled="disabled"
              :list.sync="form.assetAccessoriesInformations"
            />
          </template>
          <template v-loading="loading">
            <title-name title="金额与折旧信息" />
            <BForm
              :config="form2Config"
              :form="form.assetDepreciationInformation"
            />
          </template>
          <template v-loading="loading">
            <title-name title="责任人信息" />
            <BForm
              :config="form3Config"
              :form="form.assetResponsibleInformation"
            />
          </template>
          <template v-loading="loading">
            <title-name title="附件" />
            <BForm
              :config="form4Config"
              :form="form"
            />
          </template>
        </a-card>

        <a-card
          v-if="form.disposalTime"
          v-loading="loading"
        >
          <title-name title="处置信息" />
          <BForm
            :config="form5Config"
            :form="form"
          />
        </a-card>
      </BForms>
      <div class="tar page-btn-right-top">
        <a-button
          v-checkVisibleInDetail
          @click="$close"
        >
          关闭
        </a-button>
      </div>
    </div>
  </base-breadcrumb>
</template>

<script>
import assetApi from '@/api/office/asset'
import BUploadVModel from '@/components/BComponents/BUploadVModel'
import SelectPerson from '@/components/Select/SelectPerson'
import BSelect from '@/components/BComponents/BSelect'
import part from '@/views/office/assetManagement/check/part'

export default {
  name:'AssetManagementListAdd',
  components: {
        part
    },
    computed: {
      /* eslint-disable */
        formConfig() {
            return [
                {
                    row: true,
                    children: [
                        { type: 'input', value: 'unitName', label: '申请购置单位', attrs: { disabled: this.disabled } },
                        { type: 'input', value: 'depName', label: '申请购置部门', attrs: { disabled: this.disabled } },
                        { type: 'input', value: 'purchaseName', label: '申请购置人', attrs: { disabled: this.disabled } },
                        { type: 'input', value: 'assetCode', label: '资产编号', attrs: { disabled: this.disabled } },
                        {
                            type: BSelect, value: 'assetSpecies', label: '资产类别',
                            attrs: {
                                disabled: this.disabled,
                                request: () => assetApi.typesLabel({ type: 18 })
                            },
                            on: {
                                change: () => {
                                    if (this.form.assetSpecies === '605004528177254572') {
                                        this.form.assetType = ''
                                    }
                                }
                            }
                        },
                        {
                            type: BSelect, value: 'assetType', label: '资产种类',
                            show: this.form.assetSpecies === '605004528177254571',
                            attrs: {
                                disabled: this.disabled,
                                request: () => assetApi.typesLabel({ type: 19 })
                            }
                        },
                        { type: 'input', value: 'assetName', label: '资产名称', attrs: { disabled: this.disabled } },
                        {
                            type: 'input', value: 'specModel', label: '规格型号',
                            show: this.form.assetType === '605004528177254573' ||
                                this.form.assetType === '605004528177254575' ||
                                this.form.assetSpecies === '605004528177254572',
                            attrs: { disabled: this.disabled }
                        },
                        { type: 'input', value: 'unit', label: '单位', attrs: { disabled: this.disabled } },


                        /***********************资产种类：房屋建筑*****************************/
                        {
                            type: 'number', value: 'buildingArea', label: '建筑面积(m²)',
                            show: this.form.assetType === '605004528177254574',
                            attrs: { disabled: this.disabled }
                        },
                        {
                            type: 'date-picker', value: 'completionTime', label: '竣工日期',
                            show: this.form.assetType === '605004528177254574',
                            attrs: { disabled: this.disabled }
                        },
                        {
                            type: 'date-picker', value: 'useTime', label: '起用日期',
                            show: this.form.assetType === '605004528177254574',
                            attrs: { disabled: this.disabled }
                        },
                        {
                            type: BSelect, value: 'housePurpose', label: '用途',
                            show: this.form.assetType === '605004528177254574',
                            attrs: {
                                disabled: this.disabled,
                                request: () => assetApi.typesLabel({ type: 20 })
                            }
                        },
                        {
                            type: 'input', value: 'houseAddress', label: '房屋地址',
                            show: this.form.assetType === '605004528177254574',
                            attrs: { disabled: this.disabled }
                        },
                        {
                            type: 'input', value: 'useDepName', label: '使用单位', show: (this.disabled) &&
                                (this.form.assetType === '605004528177254574' || this.form.assetType === '605004528177254575'),
                            attrs: { disabled: true }
                        },

                        /***********************资产种类：房屋建筑*****************************/


                        /***********************资产种类：其他固定资产*****************************/
                        {
                            type: 'number', value: 'number', label: '数量',
                            show: this.form.assetType === '605004528177254573' || this.form.assetSpecies === '605004528177254572',
                            attrs: { disabled: this.disabled, precision: 2 }
                        },
                        {
                            type: 'input', value: 'manufactureUnit', label: '制造单位',
                            show: this.form.assetType === '605004528177254573' || this.form.assetSpecies === '605004528177254572',
                            attrs: { disabled: this.disabled }
                        },
                        {
                            type: 'input', value: 'brand', label: '品牌',
                            show: this.form.assetType === '605004528177254573' || this.form.assetSpecies === '605004528177254572',
                            attrs: { disabled: this.disabled }
                        },
                        {
                            type: 'date-picker', value: 'leaveFactoryTime', label: '出厂日期',
                            prop: this.form.assetSpecies !== '605004528177254572' ? 'leaveFactoryTime' : '',
                            // prop: '',
                            show: this.form.assetType === '605004528177254573' || this.form.assetSpecies === '605004528177254572',
                            attrs: { disabled: this.disabled, valueFormat: 'x' }
                        },
                        /***********************资产种类：其他固定资产*****************************/


                        /***********************资产种类：汽车*****************************/
                        {
                            type: 'input', value: 'license', label: '车牌号',
                            show: this.form.assetType === '605004528177254575',
                            attrs: { disabled: this.disabled }
                        },
                        {
                            type: 'date-picker', value: 'useTime', label: '起用日期',
                            show: this.form.assetType === '605004528177254575',
                            attrs: { disabled: this.disabled, valueFormat: 'x' }
                        },
                        {
                            type: 'input', value: 'useAddress', label: '使用地点',
                            show: this.form.assetType === '605004528177254575',
                            attrs: { disabled: this.disabled }
                        },
                        {
                            type: 'input', value: 'carPurchase', label: '用途',
                            show: this.form.assetType === '605004528177254575',
                            attrs: { disabled: this.disabled }
                        },
                        {
                            type: 'input', value: 'fuelType', label: '燃油类别',
                            show: this.form.assetType === '605004528177254575',
                            attrs: { disabled: this.disabled }
                        },
                        {
                            type: 'input', value: 'engineNumber', label: '发动机号',
                            show: this.form.assetType === '605004528177254575',
                            attrs: { disabled: this.disabled }
                        },
                        {
                            type: 'input', value: 'chassisNumber', label: '车架号',
                            show: this.form.assetType === '605004528177254575',
                            attrs: { disabled: this.disabled }
                        },
                        {
                            type: 'input', value: 'productionUnit', label: '生产单位',
                            show: this.form.assetType === '605004528177254575',
                            attrs: { disabled: this.disabled }
                        },
                        /***********************资产种类：汽车*****************************/



                        {
                            type: 'date-picker', value: 'acceptanceTime', label: '验收日期',
                            attrs: { disabled: this.disabled, valueFormat: 'x' }
                        }
                    ]
                }
            ]
        },
        form2Config() {
            return [
                {
                    row: true,
                    children: [
                        {
                            type: 'number', value: 'originalValue', label: '原值(元)',
                            attrs: { disabled: this.disabled, precision: 2 },
                            on: { change: this.calcTotal }
                        },
                        {
                            type: 'number', value: 'incidentals', label: '杂费(元)',
                            attrs: { disabled: this.disabled, precision: 2 },
                            on: { change: this.calcTotal }
                        },
                        {
                            type: 'number', value: 'total', label: '合计金额(元)',
                            attrs: { disabled: true, precision: 2 }
                        },
                        {
                            type: 'number', value: 'durableYears', label: '使用年限(年)',
                            attrs: { disabled: this.disabled, min: 0, isInt: true, placeholder: '' }
                        },
                        {
                            type: 'number', value: 'salvage', label: '残值率(%)',
                            attrs: { disabled: this.disabled, precision: 2, min: 0, max: 100, placeholder: '' }
                        },
                        {
                            type: 'number', value: 'discountMonth', label: '折旧年限(月)',
                            attrs: { disabled: this.disabled, precision: 2, placeholder: '' }
                        },
                        {
                            type: 'number', value: 'discountMoney', label: '已提折旧(元)',
                            attrs: { disabled: this.disabled, precision: 2, placeholder: '' }
                        },
                        {
                            type: 'number', value: 'netValue', label: '净值(元)',
                            attrs: { disabled: this.disabled, precision: 2, placeholder: '' }
                        },
                        {
                            type: 'number', value: 'salvageValue', label: '残值(元)',
                            attrs: { disabled: this.disabled, precision: 2, placeholder: '' }
                        }
                    ]
                }
            ]
        },
        form3Config() {
            return [
                {
                    row: true,
                    children: [
                        { type: 'input', value: 'headName', label: '负责人', attrs: { disabled: this.disabled } },
                        { type: 'input', value: 'acceptorName', label: '技术验收人', attrs: { disabled: this.disabled } },
                        { type: 'input', value: 'keepUnitName', label: '保管单位', attrs: { disabled: this.disabled } },
                        { type: 'input', value: 'keepDepName', label: '保管部门', attrs: { disabled: this.disabled } },
                        { type: 'input', value: 'keeptorName', label: '保管人', attrs: { disabled: this.disabled } }
                    ]
                }
            ]
        },
        form4Config() {
            return [
                {
                    row: true,
                    children: [
                        {
                            type: BUploadVModel, value: 'assetEnquiryFiles', label: '资产询价记录', colSpan: 24,
                            show: this.form.assetSpecies !== '605004528177254572',
                            attrs: { disabled: true, businessCode: 'UN09' }
                        },
                        {
                            type: BUploadVModel, value: 'assetPurchaseFiles', label: '购置申请', colSpan: 24,
                            attrs: { disabled: true, businessCode: 'UN09' }
                        },
                        {
                            type: BUploadVModel, value: 'assetInvoiceFiles', label: '发票复印件', colSpan: 24,
                            attrs: { disabled: true, businessCode: 'UN09' }
                        },
                        {
                            type: BUploadVModel, value: 'assetOtherFiles', label: '其他', colSpan: 24,
                            attrs: { disabled: true, businessCode: 'UN09' }
                        }
                    ]
                }
            ]
        },
        form5Config() {
            return [
                {
                    row: true,
                    children: [
                        {
                            type: 'input', value: 'disposalName', label: '处置人',
                            attrs: { disabled: this.disabled, placeholder: '' }
                        },
                        {
                            type: 'date-picker', value: 'disposalTime', label: '处置日期',
                            attrs: { disabled: this.disabled, placeholder: '' }
                        },
                        {
                            type: BUploadVModel, value: 'assetDisposalFiles', label: '处置报告',
                            attrs: { disabled: this.disabled, businessCode: 'UN09', uploadType: 'single' }
                        },
                        {
                            type: BUploadVModel, value: 'assetDisposalApplyFiles', label: '处置申请表',
                            attrs: { disabled: this.disabled, businessCode: 'UN09', uploadType: 'single' }
                        },
                        {
                            type: BUploadVModel, value: 'assetAuthenticateFiles', label: '第三方鉴定书',
                            attrs: { disabled: this.disabled, businessCode: 'UN09', uploadType: 'single' }
                        },
                        {
                            type: BUploadVModel, value: 'assetDisposalPhotoFiles', label: '处置资产照片',
                            attrs: { disabled: this.disabled, businessCode: 'UN09', uploadType: 'image-single' }
                        }
                    ]
                }
            ]
        }
    },
    data() {
        return {
            disabled: true,
            loading: false,
            form: {
                useDepName: '',
                useDepId: '',
                unitId: '',
                depId: '',
                purchaseId: '',
                assetSpecies: '',
                assetType: '',
                disposalTime: '',
                disposalName: '',
                assetAccessoriesInformations: [],
                assetDepreciationInformation: {
                    originalValue: '',
                    incidentals: '',
                    durableYears: '',
                    salvage: '',
                    total: ''
                },
                assetResponsibleInformation: {
                    headId: '',
                    headName: '',
                    acceptorId: '',
                    acceptorName: '',
                    keepDepId: '',
                    keepUnitId: '',
                    keeptorId: ''
                },
                assetPurchaseFiles: [],
                assetOtherFiles: [],
                assetInvoiceFiles: [],
                assetEnquiryFiles: [],
                assetDisposalFiles: [],
                assetDisposalApplyFiles: [],
                assetAuthenticateFiles: [],
                assetDisposalPhotoFiles: []
            },
            form1: {
                unitId: '',
                depId: '',
                purchaseId: '',
                // "unitId": "63816eebd9fd4b8fb9ebcc923c32cebb",
                // "depId": "40d4e599dd8140e38367d0a8a13baf39",
                // "purchaseId": "08bef3439561471f8c9fb46b4edf1741",
                'assetSpecies': '605004528177254572',
                'assetType': '',
                'assetAccessoriesInformations': [
                    {
                        'id': 1620637516635,
                        'amount': '3',
                        'designation': '1',
                        'specificationModel': '2'
                    }
                ],
                'assetDepreciationInformation': {
                    'originalValue': 1,
                    'incidentals': 2,
                    'durableYears': 3,
                    'salvage': 4,
                    'total': 3
                },
                'assetResponsibleInformation': {
                    'headId': '942c2d1179df4ae4bcda12c87fe69539',
                    'headName': '周勇',
                    'acceptorId': 'ea616a5abf58431980e0f3eeab775256',
                    'acceptorName': '李云祥',
                    keepDepId: '',
                    keepUnitId: '',
                    keeptorId: ''
                },
                'assetPurchaseFiles': [
                    {
                        'id': '82807f55fe934eab9a0a5f4b1c2dc57b',
                        'commonId': '708967991542419456',
                        'fileId': '9406D8AAFEB8FB807F9F9C5F0E032030',
                        'fileName': '2',
                        'fileType': 'image/png',
                        'suffixName': '.png',
                        'fileDesc': null,
                        'fileSize': '61427',
                        'relaPath': null,
                        'createTime': '2021-05-10',
                        'createPerson': '08bef3439561471f8c9fb46b4edf1741',
                        'updateTime': '2021-05-10',
                        'updatePerson': '08bef3439561471f8c9fb46b4edf1741',
                        'formDesc': null,
                        'rootPath': null,
                        'alias': '9406D8AAFEB8FB807F9F9C5F0E032030.png',
                        'originalFileName': null,
                        'url': '/api/ycloud-file-center/oper/download?access_token=0818b79be266000367020f172a4befbe&fileId=9406D8AAFEB8FB807F9F9C5F0E032030',
                        'uid': '82807f55fe934eab9a0a5f4b1c2dc57b',
                        'name': '2',
                        'percent': 100
                    }
                ],
                'assetOtherFiles': [
                    {
                        'id': 'd2353ee840bb4cdbb3340eff88c3f9ec',
                        'commonId': '708968011301785600',
                        'fileId': '044E961B4D12D1FAACE48FBA0984D28B',
                        'fileName': '2',
                        'fileType': 'image/png',
                        'suffixName': '.png',
                        'fileDesc': null,
                        'fileSize': '61427',
                        'relaPath': null,
                        'createTime': '2021-05-10',
                        'createPerson': '08bef3439561471f8c9fb46b4edf1741',
                        'updateTime': '2021-05-10',
                        'updatePerson': '08bef3439561471f8c9fb46b4edf1741',
                        'formDesc': null,
                        'rootPath': null,
                        'alias': '044E961B4D12D1FAACE48FBA0984D28B.png',
                        'originalFileName': null,
                        'url': '/api/ycloud-file-center/oper/download?access_token=0818b79be266000367020f172a4befbe&fileId=044E961B4D12D1FAACE48FBA0984D28B',
                        'uid': 'd2353ee840bb4cdbb3340eff88c3f9ec',
                        'name': '2',
                        'percent': 100
                    }
                ],
                'assetInvoiceFiles': [
                    {
                        'id': 'b0ead4183ec346c3822fad914d53033f',
                        'commonId': '708967999872307200',
                        'fileId': '1A0BCA41DBF796C82CF42DCC76E951F3',
                        'fileName': '2',
                        'fileType': 'image/png',
                        'suffixName': '.png',
                        'fileDesc': null,
                        'fileSize': '61427',
                        'relaPath': null,
                        'createTime': '2021-05-10',
                        'createPerson': '08bef3439561471f8c9fb46b4edf1741',
                        'updateTime': '2021-05-10',
                        'updatePerson': '08bef3439561471f8c9fb46b4edf1741',
                        'formDesc': null,
                        'rootPath': null,
                        'alias': '1A0BCA41DBF796C82CF42DCC76E951F3.png',
                        'originalFileName': null,
                        'url': '/api/ycloud-file-center/oper/download?access_token=0818b79be266000367020f172a4befbe&fileId=1A0BCA41DBF796C82CF42DCC76E951F3',
                        'uid': 'b0ead4183ec346c3822fad914d53033f',
                        'name': '2',
                        'percent': 100
                    }
                ],
                'assetEnquiryFiles': [
                    {
                        'id': 'de9dab3bbdab4e979cda4af19de7a3d3',
                        'commonId': '708967983871037440',
                        'fileId': '86109665DD0D11F7DFD4F29AA59DB731',
                        'fileName': '2',
                        'fileType': 'image/png',
                        'suffixName': '.png',
                        'fileDesc': null,
                        'fileSize': '61427',
                        'relaPath': null,
                        'createTime': '2021-05-10',
                        'createPerson': '08bef3439561471f8c9fb46b4edf1741',
                        'updateTime': '2021-05-10',
                        'updatePerson': '08bef3439561471f8c9fb46b4edf1741',
                        'formDesc': null,
                        'rootPath': null,
                        'alias': '86109665DD0D11F7DFD4F29AA59DB731.png',
                        'originalFileName': null,
                        'url': '/api/ycloud-file-center/oper/download?access_token=0818b79be266000367020f172a4befbe&fileId=86109665DD0D11F7DFD4F29AA59DB731',
                        'uid': 'de9dab3bbdab4e979cda4af19de7a3d3',
                        'name': '2',
                        'percent': 100
                    }
                ],
                'unitName': '63816eebd9fd4b8fb9ebcc923c32cebb',
                'depIdName': '',
                'depName': '机电部',
                'purchaseName': '今晚全场尹公子买单',
                'number': 1,
                'assetName': '1',
                'specModel': '2',
                'unit': '3',
                'manufactureUnit': '5',
                'brand': '6',
                'leaveFactoryTime': '1620378298331',
                'acceptanceTime': '1620464712993'
            }
        }
    },
    created: async function() {
        if (this.$route.query.id) {
            this.form.id = this.$route.query.id
            await this.getBaseInfo()
        }
    },
    methods: {
        async getBaseInfo() {
            this.loading = true
            let res = await assetApi.findByIdParameter({}, { id: this.form.id })
            if (res.code === this.SUCCESS_CODE) {
                this.form = res.data
            }
            this.loading = false
        }
    }
}
</script>
